#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
int high,width;
int bird_x,bird_y;
int bar1_y,bar1_xtop,bar1_xdown;
void gotoxy(int x,int y)
{
	HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
	COORD pos;
	pos.X=x;
	pos.Y=y;
	SetConsoleCursorPosition(handle,pos);
 } 
 void startup()
 {
 	high=24;
 	width=50;
 	bird_x=0;
 	bird_y=width/4;
 	bar1_y=width/2;
 	bar1_xtop=high/2;
 	bar1_xdown=high/3;
 }
 void show()
 {
 	gotoxy(0,0);
 	int i,j;
 	for(i=0;i<high;i++)
 	{
 		for(j=0;j<width;j++)
 		{
 			if((i==bird_x)&&(j==bird_y))
 			    printf("@");
 			else if((j==bar1_y)&&((i>bar1_xtop)||(i<bar1_xdown)))
			    printf("*"); 
 			else 
 			    printf(" ");
		 }
		 printf("\n");
	 }
 }
 void updateWithoutInput()
 {
 	bird_x++;
 	Sleep(100);
 }
 void updateWithInput()
 {
 	char input;
 	if(kbhit())
 	{
 		input=getch();
 		if(input==' ')
 		    bird_x=bird_x-2;
	 }
 }
int main()
{
	startup();
	while(1)
	{
		show();
		updateWithoutInput();
		updateWithInput();
	}
	return 0;
}
